using System;
using System.Collections.Generic;

namespace OffsetPath
{
    public class ClassG : ClassAk
    {
        private PuntoDueD a;
        public double b;

        public ClassG()
        {
            this.a = new PuntoDueD();
        }

        public ClassG(ClassG A_0)
        {
            this.a = new PuntoDueD();
            this.a.e(A_0.d());
            this.b = A_0.b;
        }

        public ClassG(PuntoDueD A_0, double A_1)
        {
            this.a = new PuntoDueD();
            this.a.e(A_0);
            this.b = A_1;
        }

        public void MethodA(ClassAd A_0)
        {
            PuntoDueD puntoDueD = A_0.k();
            var a = new ForseLineaClassA(A_0.l(), A_0.o());
            double num = new ClassAtPuntoIncrementale(a.a, puntoDueD).MethodB(a.b);
            double num2 = a.b.c();
            num /= num2;
            double num3 = num / num2;
            var at = new ClassAtPuntoIncrementale(a.b);
            at.d(num3);
            PuntoDueD x2 = new PuntoDueD(a.a.X + at.a, a.a.Y + at.b);
            this.MethodB(puntoDueD, puntoDueD.MethodC(x2));
        }

        public void MethodA(ClassG A_0)
        {
            this.a.e(A_0.d());
            this.b = A_0.b;
        }

        public bool MethodA(PuntoDueD A_0)
        {
            return (this.a.MethodC(A_0) < this.b);
        }

        public bool MethodA(ForseLineaClassA A_0, List<PuntoDueD> A_1)
        {
            double num = A_0.a.MethodC(this.a);
            var a = new ForseLineaClassA(A_0);
            a.b.MethodA((double)((num + this.b) * 2.0));
            return this.MethodB(a, A_1);
        }

        public bool MethodA(ClassG A_0, List<PuntoDueD> A_1)
        {
            double a = this.a.X;
            double b = this.a.Y;
            double num3 = this.b;
            double num4 = A_0.d().X;
            double num5 = A_0.d().Y;
            double num6 = A_0.b;
            double num7 = A_0.d().MethodC(this.a);
            if (num7 == 0.0)
            {
                return false;
            }
            if (num7 == (num3 + num6))
            {
                var at = new ClassAtPuntoIncrementale(this.a, A_0.d());
                at.MethodA(num3);
                PuntoDueD puntoDueD = new PuntoDueD(this.a.MethodB(at));
                A_1.Add(puntoDueD);
                return true;
            }
            if ((num7 > (num3 + num6)) || (num7 < Math.Abs((double)(num3 - num6))))
            {
                return false;
            }
            double d = ((((num7 + num3) + num6) * ((num7 + num3) - num6)) * ((num7 - num3) + num6)) * ((-num7 + num3) + num6);
            d = Math.Sqrt(d) / 4.0;
            double num9 = ((a + num4) / 2.0) - (((a - num4) * ((num3 * num3) - (num6 * num6))) / ((2.0 * num7) * num7));
            double num10 = ((2.0 * (b - num5)) * d) / (num7 * num7);
            double num11 = ((b + num5) / 2.0) - (((b - num5) * ((num3 * num3) - (num6 * num6))) / ((2.0 * num7) * num7));
            double num12 = ((2.0 * (a - num4)) * d) / (num7 * num7);
            PuntoDueD item = new PuntoDueD(num9 + num10, num11 - num12);
            PuntoDueD x3 = new PuntoDueD(num9 - num10, num11 + num12);
            A_1.Add(item);
            A_1.Add(x3);
            return true;
        }

        public bool MethodA(PuntoDueD A_0, double A_1)
        {
            return (this.a.MethodC(A_0) < (this.b + A_1));
        }

        public void MethodA(PuntoDueD A_0, PuntoDueD A_1)
        {
            var at = new ClassAtPuntoIncrementale(A_0, A_1);
            at.d((double)0.5);
            this.b = at.c();
            this.a.e(A_0.MethodB(at));
        }

        public double MethodA(ForseLineaClassA A_0, PuntoDueD A_1, PuntoDueD A_2)
        {
            ClassAj aj = new ClassAj();
            this.k(A_0, aj);
            if (aj.a < 0.0)
            {
                A_2.e(A_0.a);
                return this.MethodB(A_0.a, A_1);
            }
            double num = A_0.g();
            if (aj.b > num)
            {
                PuntoDueD puntoDueD = new PuntoDueD(A_0.i());
                A_2.e(puntoDueD);
                return this.MethodB(puntoDueD, A_1);
            }
            List<PuntoDueD> list = new List<PuntoDueD>();
            if (this.MethodB(A_0, list))
            {
                A_1.e(list[0]);
                A_2.e(list[0]);
                return 0.0;
            }
            if (((aj.b > 0.0) && (aj.a < num)) && this.MethodA(A_0.a))
            {
                double num2 = this.MethodB(A_0.a, A_1);
                PuntoDueD x2 = new PuntoDueD();
                double num3 = this.MethodB(A_0.i(), x2);
                if (num3 > num2)
                {
                    A_1.e(x2);
                    A_2.e(A_0.i());
                    return num3;
                }
                A_2.e(A_0.a);
                return num2;
            }
            double num4 = (aj.a + aj.b) / 2.0;
            if (num4 > 0.0)
            {
                if (num4 < num)
                {
                    double num5 = num4 / num;
                    var at = new ClassAtPuntoIncrementale(A_0.b);
                    at.d(num5);
                    PuntoDueD x3 = new PuntoDueD(A_0.a.MethodB(at));
                    A_2.e(x3);
                    return this.MethodB(x3, A_1);
                }
                PuntoDueD x4 = new PuntoDueD(A_0.i());
                A_2.e(x4);
                return this.MethodB(x4, A_1);
            }
            A_2.e(A_0.a);
            return this.MethodB(A_0.a, A_1);
        }

        public double MethodA(ClassG A_0, PuntoDueD A_1, PuntoDueD A_2)
        {
            double num = this.a.MethodC(A_0.d());
            double b = A_0.b;
            double num3 = (num - this.b) - b;
            if (num3 > 0.0)
            {
                var a = new ForseLineaClassA(this.a, A_0.d());
                a.b.MethodA(this.b);
                A_1.e(a.i());
                a.b.d();
                a.MethodA(A_0.d());
                a.b.MethodA(A_0.b);
                A_2.e(a.i());
                return num3;
            }
            if ((num + this.b) < b)
            {
                num3 = (num + this.b) - b;
                var at = new ClassAtPuntoIncrementale(A_0.d(), this.d());
                at.d((double)(this.b / num));
                A_1.e(this.a.MethodB(at));
                at.d((double)(num3 / this.b));
                A_2.e(A_1.MethodB(at));
                return num3;
            }
            if ((num + b) < this.b)
            {
                num3 = (num + b) - this.b;
                var at2 = new ClassAtPuntoIncrementale(this.a, A_0.d());
                at2.d((double)(b / num));
                A_2.e(A_0.d().MethodB(at2));
                at2.d((double)(num3 / b));
                A_1.e(A_2.MethodB(at2));
                return num3;
            }
            num3 = 0.0;
            List<PuntoDueD> list = new List<PuntoDueD>();
            if (this.MethodA(A_0, list))
            {
                A_1.e(list[0]);
                A_2.e(A_1);
                return num3;
            }
            return 0.0;
        }

        public void MethodA(PuntoDueD A_0, PuntoDueD A_1, PuntoDueD A_2)
        {
            this.MethodA(new ClassAd(A_0, A_1, A_2));
        }

        private double MethodB()
        {
            return (ClassK.ad * this.b);
        }

        public bool MethodB(ClassAd A_0)
        {
            if (A_0.n())
            {
                return false;
            }
            this.a.e(A_0.MethodB());
            this.b = this.a.MethodC(A_0.l());
            return true;
        }

        public bool MethodB(ForseLineaClassA A_0, List<PuntoDueD> A_1)
        {
            double a = A_0.a.X;
            double num2 = A_0.a.X + A_0.b.a;
            double num3 = this.a.X;
            double b = A_0.a.Y;
            double num5 = A_0.a.Y + A_0.b.b;
            double num6 = this.a.Y;
            double num7 = this.b;
            double num8 = ((num2 - a) * (num2 - a)) + ((num5 - b) * (num5 - b));
            double num9 = 2.0 * (((num2 - a) * (a - num3)) + ((num5 - b) * (b - num6)));
            double num10 = (((((num3 * num3) + (num6 * num6)) + (a * a)) + (b * b)) - (2.0 * ((num3 * a) + (num6 * b)))) - (num7 * num7);
            double num11 = -num9 / (2.0 * num8);
            PuntoDueD puntoDueD = new PuntoDueD();
            if (num11 < 0.0)
            {
                puntoDueD.e(A_0.a);
            }
            else if (num11 > 1.0)
            {
                puntoDueD.e(A_0.i());
            }
            else
            {
                var at = new ClassAtPuntoIncrementale(A_0.b);
                at.d(num11);
                puntoDueD = A_0.a.MethodB(at);
            }
            if (puntoDueD.MethodC(this.a) > this.b)
            {
                return false;
            }
            double d = (num9 * num9) - ((4.0 * num8) * num10);
            if (d < 0.0)
            {
                return false;
            }
            if (d == 0.0)
            {
                double num13 = -num9 / (2.0 * num8);
                A_1.Add(A_0.c(num13));
                return true;
            }
            d = Math.Sqrt(d);
            double num14 = (-num9 + d) / (2.0 * num8);
            double num15 = (-num9 - d) / (2.0 * num8);
            bool flag = false;
            if ((num15 >= 0.0) && (num15 <= 1.0))
            {
                flag = true;
                A_1.Add(A_0.c(num15));
            }
            if ((num14 >= 0.0) && (num14 <= 1.0))
            {
                flag = true;
                A_1.Add(A_0.c(num14));
            }
            return flag;
        }

        public void MethodB(PuntoDueD A_0, double A_1)
        {
            this.a.e(A_0);
            this.b = A_1;
        }

        public double MethodB(PuntoDueD A_0, PuntoDueD A_1)
        {
            double num = this.a.MethodC(A_0);
            if (num == 0.0)
            {
                var at = new ClassAtPuntoIncrementale(this.b, 0.0);
                A_1.e(this.a.MethodB(at));
            }
            else
            {
                var a = new ForseLineaClassA(this.a, A_0);
                a.b.MethodA(this.b);
                A_1.e(a.i());
            }
            return (num - this.b);
        }

        public bool MethodB(PuntoDueD A_0, PuntoDueD A_1, PuntoDueD A_2)
        {
            if (ClassAd.f(A_0, A_1, A_2))
            {
                return false;
            }
            this.a.e(ClassAd.d(A_0, A_1, A_2));
            this.b = this.a.MethodC(A_0);
            return true;
        }

        public double c()
        {
            return ((ClassK.s * this.b) * this.b);
        }

        public override double MethodC(PuntoDueD A_0)
        {
            return (this.a.MethodC(A_0) - this.b);
        }

        public void c(PuntoDueD A_0, PuntoDueD A_1, PuntoDueD A_2)
        {
            double num = A_0.MethodC(A_1);
            double num2 = A_1.MethodC(A_2);
            double num3 = A_2.MethodC(A_0);
            if ((num >= num2) && (num >= num3))
            {
                this.MethodA(A_0, A_1);
                if (this.MethodA(A_2))
                {
                    return;
                }
            }
            else if (num2 >= num3)
            {
                this.MethodA(A_1, A_2);
                if (this.MethodA(A_0))
                {
                    return;
                }
            }
            else
            {
                this.MethodA(A_2, A_0);
                if (this.MethodA(A_1))
                {
                    return;
                }
            }
            this.MethodB(A_0, A_1, A_2);
        }

        public PuntoDueD d()
        {
            return this.a;
        }

        public override void f(ClassAb A_0)
        {
            A_0.MethodA(this.a.X - this.b, this.a.Y + this.b, this.a.X + this.b, this.a.Y - this.b);
        }

        ~ClassG()
        {
        }

        public override void k(ForseLineaClassA A_0, ClassAj A_1)
        {
            var a = new ForseLineaClassA(this.a, A_0.b);
            a.b.MethodA((double)(this.b * 2.0));
            var at = new ClassAtPuntoIncrementale(a.b);
            at.d((double)-0.5);
            a.p(at);
            a.k(A_0, A_1);
        }

        public override void l(ClassAtPuntoIncrementale A_0, ClassAj A_1)
        {
            var a = new ForseLineaClassA(this.a, A_0);
            a.b.MethodA((double)(this.b * 2.0));
            var at = new ClassAtPuntoIncrementale(A_0);
            at.d((double)-0.5);
            a.p(at);
            a.l(A_0, A_1);
        }

        public override void n(ClassAg A_0)
        {
            this.a.n(A_0);
            double d = Math.Abs((double)(this.b / A_0.MethodB())) + 0.5;
            d = Math.Floor(d);
            if (this.b < 0.0)
            {
                this.b = -d * A_0.MethodB();
            }
            else
            {
                this.b = d * A_0.MethodB();
            }
        }

        public override void o(double A_0, PuntoDueD A_1)
        {
            this.a.o(A_0, A_1);
            this.b *= A_0;
        }

        public override void p(ClassAtPuntoIncrementale A_0)
        {
            this.a.p(A_0);
        }

        public override void q(ForseLineaClassA A_0)
        {
            this.a.q(A_0);
        }

        public override void r(PuntoDueD A_0)
        {
            this.a.r(A_0);
        }

        public override void GetStartPoint(double A_0, PuntoDueD A_1)
        {
            this.a.GetStartPoint(A_0, A_1);
        }
    }
}

